import React, {Component} from 'react';
import {StyleSheet, Image, Text, View} from 'react-native';
import {Flex} from '@ant-design/react-native';
import moment from 'moment';

class HCard extends Component {
    constructor(props) {
        super(props);
    }

    render() {
        return (
            <View
                style={{
                    width: '100%',
                    borderRadius: 9,
                    backgroundColor: 'white',
                }}>
                <View style={{width: '100%', height: 118, borderRadius: 9, backgroundColor: '#d3d3d3'}}>
                    <Image style={styles.headerImage} source={require('~/assets/shouye/shouyedemo.png')} />
                </View>
                <View
                    style={{
                        width: '100%',
                        height: 'auto',
                        marginTop: 0 ,
                        paddingHorizontal: 5,
                    }}>
                    <Flex justify={'between'} style={styles.infoHead}>
                        <Text numberOfLines={1} style={styles.infoTitle}>
                            {this.props.item.BuildingName}
                        </Text>
                        <View style={{width: '22%'}}>
                            <View style={{backgroundColor: '#d61616', borderRadius:3}}>
                                <Text numberOfLines={1} style={{color: 'white', textAlign: 'center', fontSize: 8, padding: 1}}>
                                    {this.props.item.RentType == 0 ? '出租' : '出售'}
                                </Text>
                            </View>
                        </View>
                    </Flex>
                    <Flex>
                        <Text numberOfLines={1} style={styles.infoPrice}>
                            价格:
                            {this.props.item.RentType == 0 ? (
                                <Text
                                    numberOfLines={1}
                                    style={{
                                        fontSize: 14,
                                    }}>
                                    {this.props.item.PriceRent}元/月
                                </Text>
                            ) : (
                                <Text
                                    numberOfLines={1}
                                    style={{
                                        fontSize: 14,
                                    }}>
                                    {this.props.item.PriceSell}元
                                </Text>
                            )}
                        </Text>
                    </Flex>
                    <Flex justify={'between'} style={styles.time}>
                        <Text style={styles.infoTime}>{moment(this.props.item.RegDateTime).format('YYYY.MM.DD')}</Text>
                    </Flex>
                </View>
            </View>
        );
    }
}

const styles = StyleSheet.create({
    mainView: {
        width: '100%',
        borderRadius: 9,
        backgroundColor: 'white',
    },
    headerImage: {
        width: '100%',
        height: 118,
        //resizeMode: 'contain',
        borderTopLeftRadius: 10,
        borderTopRightRadius: 10,
    },
    infoView: {
        width: '100%',
        height: 'auto',
        paddingHorizontal: 5,
    },
    infoHead: {
        paddingTop: 8,
        paddingLeft: 3,
        paddingRight: 5,
        height: 30,
        width: '100%',
        marginTop: 10,
    },
    infoTitle: {
        fontSize: 14,
        color: '#080103',
        width: '70%',
    },
    hdflex: {
        marginBottom: 7,
        marginTop: 10,
    },
    infoTag: {
        borderRadius: 3,
        backgroundColor: '#E3291F',
        marginLeft: 6,
        paddingHorizontal: 4.5,
        paddingVertical: 1,
    },
    infoTagText: {
        fontSize: 12,
        backgroundColor: 'transparent',
        color: 'white',
    },
    infoParams: {
        fontSize: 12,
        color: '#333333',
        marginBottom: 7,
        paddingLeft: 9,
    },
    infoPrice: {
        fontSize: 10,
        color: '#CE2D32',
        marginTop: 10,
        paddingLeft: 3,
    },
    time: {
        paddingLeft: 3,
        paddingRight: 5,
        width: '100%',
        marginBottom: 10,
    },
    infoTime: {
        width: '66%',
        fontSize: 9,
        color: '#B59C7B',
        marginTop: 8,
    },
});

export default HCard;
